
// 路由前置守卫
import { store } from '@/utils/helper'
import {  Router } from 'vue-router'
import { whiteList } from './whiteList'
class routerGuard{
   public router:Router
   public whiteList = whiteList
   constructor( agrRouter :Router){
        this.router = agrRouter
   }

    public run(){
        this.router.beforeEach((to,from,next)=>{
            const token = store.get('token')
            

             if(!token && !this.whiteList.includes(to.path)){
              next('/auth/login')
             }else{
              next()
             }
          })
    }
}

export default   (router:Router)=>{
    new routerGuard(router).run()
}
